from pydantic import BaseModel, Field
from datetime import datetime
from typing import List


class InterfaceStatistic(BaseModel):
    """
    业务数据统计结果
    """
    success: int = Field(title='成功访问的接口总次数')
    exc: int = Field(title='异常访问的接口总次数')


class InterfaceFreq(BaseModel):
    """
    接口调用频率统计结果
    """
    start_time: datetime
    end_time: datetime
    count: int = Field(title='访问次数')


class ExcClassifyStatistic(BaseModel):
    """
    异常分类统计
    """
    exc_klass: str = Field(title='异常的名称')
    count: int = Field(title='出现次数')


class KeyBusiness(BaseModel):
    """
    关键业务的访问情况
    """
    api_name: str = Field(title='接口 URL')
    count: int = Field(title='访问次数')


class KeyBusinessStatistic(BaseModel):
    """
    关键业务的访问情况
    """
    seq: List[KeyBusiness] = Field(title='所有关键业务的访问情况')


class ExceptionInfo(BaseModel):
    """
    异常信息
    """
    time: datetime = Field(title='异常发生时间')
    info: str = Field(title='异常的报错信息')
